<?php

namespace JsonLowCode\Form\Fields;

use JsonLowCode\Schema;
use JsonLowCode\Form\Rule;

/**
 * Form表单password输入框组件
 */
class PasswordField extends TextField
{
    protected string $type = "password";
    protected function booted(): void
    {
        parent::booted();
        $this->showPasswordOn("click");
    }

    /**
     * 显示密码的触发时机
     * @param string $showPasswordOn 'click' | 'mousedown'
     * @return $this
     */
    public function showPasswordOn(string $showPasswordOn = 'click' | 'mousedown'): static
    {
        $this->element->prop("show-password-on",$showPasswordOn);
        return $this;
    }

    /**
     * 密码关闭时的密码开关图标
     * @param Schema $value
     * @return $this
     */
    public function slotInvisibleIcon(Schema $value): static
    {
        $this->element->slot("password-invisible-icon",$value);
        return $this;
    }

    /**
     * 密码显示时的密码开关图标
     * @param Schema $value
     * @return $this
     */
    public function slotVisibleIcon(Schema $value): static
    {
        $this->element->slot("password-visible-icon",$value);
        return $this;
    }


}
